Update microcode.c to linux-2.6.16-rc5 codebase.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 6 Mar 2006 14:39:48 +0000 (15:39 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 6 Mar 2006 14:39:48 +0000 (15:39 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/microcode.c
xen/include/asm-x86/processor.h

index a7bd0e5d68bbb003d75a446486bdaf550a8a4814..2e31eea4802a495119f41d042217fc8f5d07dbc2 100644 (file)
@@ -116,7 +116,7 @@ MODULE_LICENSE("GPL");
 #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
 
 /* serialize access to the physical write to MSR 0x79 */
-static spinlock_t microcode_update_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(microcode_update_lock);
 
 /* no concurrent ->write()s are allowed on /dev/cpu/microcode */
 static DECLARE_MUTEX(microcode_sem);
@@ -166,7 +166,8 @@ static void collect_cpu_info (void *unused)
        }
 
        wrmsr(MSR_IA32_UCODE_REV, 0, 0);
-       __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+       /* see notes above for revision 1.07.  Apparent chip bug */
+       sync_core();
        /* get the current revision from MSR 0x8B */
        rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
        pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
@@ -366,7 +367,7 @@ static void do_update_one (void * unused)
        struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
 
        if (uci->mc == NULL) {
-               printk(KERN_INFO "microcode: No suitable data for CPU%d\n", cpu_num);
+               printk(KERN_INFO "microcode: No new microcode data for CPU%d\n", cpu_num);
                return;
        }
 
@@ -379,7 +380,9 @@ static void do_update_one (void * unused)
                (unsigned long) uci->mc->bits >> 16 >> 16);
        wrmsr(MSR_IA32_UCODE_REV, 0, 0);
 
-       __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+       /* see notes above for revision 1.07.  Apparent chip bug */
+       sync_core();
+
        /* get the current revision from MSR 0x8B */
        rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
 
index 8545c16c5436bd6e486f74a7d5f7314dc907c7fa..de4232f5bde2ec19204f9907ddf8753cb307e3cc 100644 (file)
@@ -353,6 +353,13 @@ static always_inline void clear_in_cr4 (unsigned long mask)
        outb((data), 0x23); \
 } while (0)
 
+/* Stop speculative execution */
+static inline void sync_core(void)
+{
+    int tmp;
+    asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
+}
+
 static always_inline void __monitor(const void *eax, unsigned long ecx,
                unsigned long edx)
 {